var tmpattr = [];

$(function() {

	$('#li_sys').addClass('active open');
	$('#topologydrawer').addClass('active');

	init();

	$("#SaveButton").click(function() {
		document.getElementById("mySavedModel").value = myDiagram.model.toJson();
		myDiagram.isModified = false;
		// console.log(myDiagram.model.toJson());
		var json = JSON.parse(myDiagram.model.toJson());

		var dclass = json.class;
		var linkFromPortIdProperty = json.linkFromPortIdProperty;
		var linkToPortIdProperty = json.linkToPortIdProperty;

		var nodeDataArray = json.nodeDataArray;
		var linkDataArray = json.linkDataArray;

		$.ajax({
			type : 'post',
			url : 'savetopology',
			dataType : 'text',					
			data : {
				"project":$("#toponame").val(),
				"dclass":dclass,
				"linkFromPortIdProperty":linkFromPortIdProperty,
				"linkToPortIdProperty":linkToPortIdProperty,
				"nodeDataArray":JSON.stringify(nodeDataArray),
				"linkDataArray":JSON.stringify(linkDataArray),
				"nodeAttrList":JSON.stringify(nodeattrlist) 
			},
			success : function(msg) {
				if(msg=='1'){
					alert("添加成功");
				}
			},
			error : function(msg) {
				console.log('failed')
			}
		});

	});

	$("#LoadButton").click(function() {
		load();
	});
	
});